package com.pro.controller;

import com.pro.pojo.JsClosure;
import com.pro.pojo.JsonData;
import com.pro.service.JsClosureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.logging.Logger;

/**
 * ClassName:JsClosureController
 * Package:com.pro.controller
 * Description:
 *
 * @Date:2021/11/17 19:49
 * @Author: ZPT
 */
@RequestMapping("/closure")
@RestController
public class JsClosureController {
    @Autowired
    private JsClosureService service;

    @RequestMapping("/addClosure")
    public JsonData addClosure(JsClosure jsClosure){
        return service.addClosure(jsClosure);
    }

    @RequestMapping("/getClosure")
    public JsonData getClosure(String userCode,String reason,String days){
        userCode = userCode!=null && userCode != ""?"%+userCode+%":"%%";
        reason = reason!=null && reason != ""?"%"+reason+"%":"%%";
        days = days!=null && days != ""?"%"+days+"%":"%%";
        List<JsClosure> closureList = service.getClosure(userCode,reason,days);
        return closureList!=null?JsonData.buildSuccess(closureList):JsonData.buildError("服务端错误");
    }
    @RequestMapping("/updateClosure")
    public JsonData updateClosure(Integer id,Integer days){
        Boolean aBoolean = service.updateClosure(id, days);
        return aBoolean!=null?JsonData.buildSuccess(aBoolean):JsonData.buildError("服务端错误");
    }
    @RequestMapping("/deleteClosure")
    public JsonData deleteClosure(Integer id){
        Boolean aBoolean = service.deleteClosure(id);
        return aBoolean!=null?JsonData.buildSuccess(aBoolean):JsonData.buildError("服务端错误");
    }
}
